home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacOberonLite 1.0.1 / Samples / ViewPict.Mod < prev   
Encoding:
Text File  |  1993-09-26  |  1.7 KB  |  61 lines  |  [TEXT/ObLi]

  1. MODULE ViewPict;    (* od jul-93 *)
  2.  
  3. (* A sample MacOberonLite program that shows how to open and
  4.    display a Macintosh PICT file. *)
  5.  
  6. IMPORT
  7.     SYSTEM, TB:= MacToolbox, ME:=MacMemory, TE:=MacText, IM:=MacImaging, MF:=MacFiles,
  8.     MP:=MacProcesses;
  9.  
  10. PROCEDURE InitMac;
  11. BEGIN
  12.     IM.InitGraf(IM.QuickDraw.thePort);
  13.     TE.InitFonts;
  14.           TB.InitWindows;
  15.           TB.InitMenus;
  16.           TE.TEInit;
  17.           TB.InitDialogs(NIL);
  18.           IM.InitCursor;
  19. END InitMac;
  20.  
  21. PROCEDURE OpenPict;
  22. VAR
  23.     myTypes  : MF.SFTypeList;
  24.           myReply  : MF.StandardFileReply;
  25.     myRef    : INTEGER;
  26.     fsize    : LONGINT;
  27.     myPic    : IM.PicHandle;
  28.     err      : INTEGER;
  29.     myWindow : TB.WindowPtr;
  30. BEGIN
  31.     myTypes[0]:=50494354H;    (* PICT *)
  32.     MF.StandardGetFile(NIL, 1, myTypes, myReply);
  33.           IF myReply.sfGood THEN
  34.         err:=MF.FSpOpenDF(myReply.sfFile, 0, myRef);
  35.                  err:=MF.GetEOF(myRef, fsize);
  36.                  err:=MF.SetFPos(myRef, 1, 512);
  37.                  DEC(fsize, 512);    (* strip PICT-header *)
  38.         SYSTEM.PUTREG(0, fsize);
  39.                  ME.NewHandle;
  40.                  SYSTEM.GETREG(8, myPic);
  41.         IF myPic=NIL THEN HALT(20) END; (* Not enough memory *)
  42.                  err:=MF.FSRead(myRef, fsize, SYSTEM.VAL(ME.Ptr, myPic.p));
  43.                  err:=MF.FSClose(myRef);  (* I left out most error checking in this demo app! *)
  44.  
  45.         myWindow:=TB.NewCWindow(NIL, IM.QuickDraw.screenBits.bounds, '', TRUE, 1,
  46.             SYSTEM.VAL(TB.WindowPtr, -1), FALSE, 0);
  47.                        IM.SetPort(myWindow);
  48.         IM.OffsetRect(myPic.p.picFrame, -myPic.p.picFrame.left, -myPic.p.picFrame.top);
  49.         IM.DrawPicture(myPic, myPic.p.picFrame);
  50.         
  51.         REPEAT UNTIL TB.Button();
  52.         TB.DisposeWindow(myWindow)
  53.     END
  54. END OpenPict;
  55.  
  56. BEGIN
  57.     InitMac;
  58.     OpenPict;
  59.     MP.ExitToShell
  60. END ViewPict.
  61.